
<div id="toolbar">
    <div class="left">
        <a href="<?php echo $this->createUrl('create'); ?>" class="icon-add">新增</a>
        <a href="javascript:void(1)" class="icon-del">删除</a>
        <a href="javascript:void(1)" class="icon-search">搜索</a>
    </div>
</div>
<script>
    $(document).ready(function (){
        $(".icon-search").click(
        function(){$(".searchPanel").toggle();
        });
   
        $(".selectAll").click(function() {
            if( $(this).attr('checked') == 'checked'){
                $(".selected").attr("checked", true);
            }else{
                $(".selected").attr("checked", false);
            }
        
        });
        $(".icon-edit").click(function() {
            $(".selected").each(function() {
                $(this).attr("checked", false);
            });
        });
        $(".icon-del").click(function (){
            var data="";
            $(".selected").each(function() {
                if( $(this).attr("checked") =="checked" ){
                    data= data+"&id[]="+$(this).val();
                }
            });
            if( data.length > 0 ){
                if( confirm('确定删除吗?') ){
                    $.getJSON('<?php echo $this->createUrl('delete'); ?>', data,
                    function(response){
                        if (response.status== 'true'){
                            window.location.reload();
                        }
                    });
                }else{
                    alert('请选择记录');
                }
            }
        });
    });
</script>